package com.tianma315.admin.invocie.view;

import com.tianma315.admin.common.base.BaseController;
import com.tianma315.admin.invocie.domain.Invoice;
import com.tianma315.admin.invocie.service.InvoiceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/invoice/view")
public class InvoiceViewController extends BaseController {

    @Autowired
    private InvoiceService invoiceService;

    @RequestMapping("/list")
    @RequiresPermissions("invoice:list")
    ModelAndView list() {
        ModelAndView view = new ModelAndView("invoice/list");
        return view;
    }


    @RequestMapping("/add")
    @RequiresPermissions("invoice:add")
    ModelAndView add() {
        ModelAndView view = new ModelAndView("invoice/add");
        return view;
    }

    @RequestMapping("/product/select")
    ModelAndView productSelect() {
        ModelAndView view = new ModelAndView("invoice/product-select");
        return view;
    }

    @RequestMapping("/agent/select")
    ModelAndView agentSelect() {
        ModelAndView view = new ModelAndView("invoice/agent-select");
        return view;
    }

    @RequestMapping("/edit/{id}")
    @RequiresPermissions("invoice:edit")
    ModelAndView edit(@PathVariable("id")Integer id) {
        ModelAndView view = new ModelAndView("invoice/edit");
        Invoice invoice = invoiceService.getInvoiceById(id);
        view.addObject("invoice",invoice);
        return view;
    }

    /**
     * 进入导入excel
     */
    @GetMapping( "/invoiceImport")
    public String invoiceImport(MultipartFile file){
        return "invoice/invoiceImport";
    }

}
